<?php
	include '../lazybox/lazybox.inc.php';
	
	//Esta clase registra un medodo php que es llamado cuando ocurre un evento
	class mylabel extends c_label{
		function __construct($id){
			parent::__construct($id);
			$this->bind_self_method('onmouseout','ax_TEST');
		}
		
		/*deben empezar con ax_  */
		function ax_TEST(){
			$id = $this->get_prop('id');
			$objResponse = new xajaxResponse();
			$objResponse->assign($id,"innerHTML",'OnMouseOut AJAX!');
			return $objResponse;
		}
	}
	
	
//gral
	$page = new c_page(__FILE__,'../lazybox');	
	$label = new mylabel('lbl1');
	$label2 = new c_label('lbl2');
	$label3 = new c_label('lbl3');
	$panel  = new c_panel('panel1');
	$txt  = new c_textbox('text1');
//estructura
	$page->add_child($panel);
	$panel->add_child($label);
	$panel->add_child($label2);
	$panel->add_child($label3);
	$panel->add_child($txt);
	
//propiedades	
	$page->set_prop('title','PRUEBA X');
	
	$label->set_props(
		array (  'text'=>'123 probando (click me)','x'=>'10','y'=>'10',
	'width'=>'200','height' => '40', 'color' =>'#202080',
	'bgcolor'=>'#909090','visible'=>'true','align'=>'right' )
		);
	
	$label2->set_props(
		array (  'text'=>'Otro label magico','x'=>'10','y'=>'220',
	'color' =>'#005000','align'=>'center','border'=>'1px solid white' )
		);
	
	$label3->set_props(
		array (  'text'=>'linklabel','link'=>'http://www.google.com' ,'x'=>'350','y'=>'50')
		);
	
$txt->set_props(	array (  'text'=>'escribime','x'=>'50','y'=>'300', 'width'=>'200',
	'color' =>'#FF0000','font.weight'=>'bold', 'validation'=>'dni' )
		);
	
	$panel->set_props(//notar que la posicion del panel afecta al label!
		array (  'x'=>'150','y'=>'50',
	'width'=>'500','height' => '500', 'bgcolor'=>'#8080a0', 'border'=>'2px solid red')
		);
		
		
//eventos	
$code="var a='I am soooo LAZY';
var flag=1;
if(flag)
	alert(a);
element.innerHTML='Mi texto cambio :P'; //con element accedo al elemento que llamo a la func
";
$label->bind_js('onclick',$code);
$label->bind_js('onclick',"alert('algo mas');");
$label2->bind_js('onmouseover',"alert('El me mouse paso por arriba!');");


	/*
$txt->bind_js('onkeyup',"alert('buhhhhhhhhhhhhh');");
*/


///////

//render precario
	echo $page->renderXHTML();
?>